<!DOCTYPE html>
<html>
<head>
    <title>我的游记</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>

</head>

<body>
    <div class="search-head">
        <div class="row nav-search">
            <div class="col">
                <a href="/mine/profiles.html">
                    <span><i class="fa fa-chevron-left"></i></span>
                </a>
            </div>
            <div class="col">
                <span>我的游记</span>
            </div>
            <div class="col"></div>
        </div>
    </div>

    <div class="container travels">
        <dl class="list" render-loop="list">
            <dd>
                <a href="editTravels.html" render-key="list.id" render-fun="handle">
                    <img render-src="list.coverUrl">
                    <h6 class="title" render-html="list.title"></h6>
                    <p>最近更新时间 <span render-html="list.lastUpdateTime"></span>
                        <span class="span-right">
                        <i class="fa fa-heart"></i><span>0</span>收藏
                        <i class="fa fa-thumbs-o-up"></i><span render-html="list.number">0</span>点赞</span>
                    </p>
                </a>
            </dd>
          <script>
              var currentPage = 1;
              var pages;
              var travels;
              
              $(function () {

                  var user = JSON.parse(sessionStorage.getItem("user"));
                  $.get("/users/" + user.id + "/travels" ,{pageSize:2},function (data) {
                     console.log(data);
                      /*  for (var i = 0 ; i<data.list.length; i++){
                           $(".praise").attr("data-index",data.list[0].id);
                           $.get("/praiseNumber", {"typeId":data.list[0].id, "type": 3}, function (num) {
                               //console.log(num.number);
                               $(".praise").html(num.number);
                           });


                       }*/
                      renderView(data);
                      pages=data.pages;
                      travels=data.list;
                  },"json");

                  $(window).scroll(function () {
                      if(isEnd()){
                          console.log("--");
                          if(currentPage<pages){
                              currentPage++;
                              $.get("/users/" + user.id + "/travels" ,{currentPage:currentPage,pageSize:2},function (data) {
                                  $.merge(travels,data.list);
                                  console.log(travels);
                                  renderView({list:travels});
                              },"json");
                          }else{
                              $(document).dialog({
                                  type:"notice",
                                  infoText:"已经到底部了",
                                  autoClose:1500,
                                  position:"center"
                              });
                          }
                      }
                  })

              })
              //var value;
              function renderView(data) {
                  $(".travels").renderValues(data,{
                      handle:function (ele,value) {
                          $(ele).attr("href","/mine/editTravels.html?id=" + value);
                          console.log(value);
                          //this.value = value;
                          //console.log(value.length);
                          //设置个标识
                       /*   $(".praise").attr("data-index",value);
                          //点赞数
                          $.get("/praiseNumber", {"typeId":value, "type": 3}, function (num) {
                              //console.log(num.number);
                              $(".praise [data-index = "+ value +']').html(num.number);
                          });*/
                      }
                  })
              }

          </script>
        </dl>
    </div>
</body>
</html>
